package com.Base.NetBase
{
	import com.Base.NetBase.P2P.*;
	import com.Base.NetBase.Socket.*;
	import com.Base.NetBase.Message.*;
	
	public class NetManager
	{
		//单件
		public function get instance():NetManager
		{
			if (null == _instance)
			{
				_instance = new NetManager(new SingletonEnforcer);
			}
			
			return _instance;
		}
		
		//构造函数
		public function NetManager(enforcer:SingletonEnforcer):void
		{
			_socket = SocketManager.instance;
			_socket.onConnected = onSocketConnected;
			_socket.onReceiveMsg = onSocketMsg;
		}
		
		//设置socket服务器ip和端口
		public function setSocketServer(ip:String, port:int):void
		{
			_socket.host = ip;
			_socket.port = port;
		}
		
		//开始连接
		public function connect():void
		{
			_socket.connect();
		}
		
		//socket连接成功
		private function onSocketConnected():void
		{
		}
		
		//收取socket服务器的消息
		private function onSocketMsg(msg:MessagePackage):void
		{
		}
		
		private static var _instance:NetManager;
		
		private var _socket	:SocketManager;
	}
}

class SingletonEnforcer
{
	
}